﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using COM.OA.Entity;
using COM.OA.BLL;
using System.Collections.Generic;
using System.Data.SqlClient;

public partial class quanxian_qx_level : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        users loginuser = Session["loginuser"] as users;
        if (loginuser == null)
        {
            this.Response.Write(string.Format(GetRedirect.ALLREDIRECT, "../login.aspx"));
        }
    }
    protected void ddl_bumen_SelectedIndexChanged(object sender, EventArgs e)
    {

        String bumen = this.ddl_bumen.Text;
        SqlParameter parambumen = new SqlParameter("@deptid", bumen);
        IList<liandongren> lists = BLLGeneric.Select<liandongren>(CommandType.StoredProcedure, "liandong", parambumen);
        this.ddl_duixiang.DataSource = lists;
        this.ddl_duixiang.DataTextField = "Em_name";
        this.ddl_duixiang.DataValueField = "Em_id";
        this.ddl_duixiang.DataBind();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        operate op = new operate();
        int u_id = Int32.Parse(this.ddl_duixiang.Text);
        int qx_id = Int32.Parse(this.qx_slelct.Text);
        if (u_id == 0)
        {
            Response.Write(string.Format(GetRedirect.WINALERT, "请选择要更改权限的用户！！"));
            Response.Write(string.Format(GetRedirect.REDIRECT, "qx_level.aspx"));
        }
        else
        {
            String where = "op_u_id='{0}' and op_pop_id='{1}'";
            where = string.Format(where, u_id, qx_id);
            IList<operate> ii = operateBLL.Select(where);
            if (ii.Count == 0)
            {
                op.op_u_id = u_id;
                op.op_pop_id = qx_id;
                int iii = operateBLL.Insert(op);
                if (iii < 0)
                {
                    Response.Write(string.Format(GetRedirect.WINALERT, "权限修改成功！！"));
                }
                else
                {
                    Response.Write(string.Format(GetRedirect.WINALERT, "权限修改失败！！"));
                }
            }
        }
        
    }
   
}
